/* eslint-disable semi */
/* eslint-disable semi */
/* eslint-disable quotes */
<template>
  <van-pull-refresh v-model="isLoading">
    <div class="all-body">
      <div class="TopList">
        <router-link to="/CashAccount">
          <van-icon class="Backlink" name="arrow-left" />
        </router-link>

        <div class="TopList-span">
          <span> 添加账户 </span>

        </div>

      </div>

      <div class="shadow"> </div>
      <div class="banner" ref="scroll">
        <!-- 轮播图 -->
        <div id="topBanner" class="hello-1">
          <van-cell-group class="cell-Group">
            <van-field v-model="compellation" class="cell-List" required label="真实姓名" placeholder="请输入您的真实姓名" />
            <van-field v-model="phone" type="tel" class="cell-List" required label="预留电话" placeholder="请输入该银行卡预留电话" />
            <van-field v-model="bank" class="cell-List" required label="开户银行" placeholder="请输入开户银行"
              right-icon="question-o" @click-right-icon="showbank()" />
            <van-field v-model="cardnumber" type="number" class="cell-List" required label="银行卡号" placeholder="请输入银行卡号"
              right-icon="question-o" @click-right-icon="showbankNumber()" />

          </van-cell-group>

        </div>

        <div class="lastadd" @click="addacount()">
          <van-button class="add-button" color="#41D08C" round type="info">添加账户</van-button>
        </div>

        <div class="adddiv"> </div>

      </div>
    </div>
  </van-pull-refresh>
</template>

<script>
import TabBar from "./TabBar.vue";
import https from "./https.js";
//引入封装好的js方法
import { _debounce, _throttle } from "./untils.js";

//引入其他子组件
export default {
  components: {
    TabBar
  },
  // eslint-disable-next-line space-before-function-paren
  data() {
    return {
      count: 0,
      isLoading: false,
      index: 0,
      message: "",
      compellation: "",
      phone: "",
      bank: "",
      cardnumber: "",
      compellationarr: ["王纪林"],
      phonearr: ["18515069755"],
      bankarr: ["招商银行"],
      cardnumberarr: ["6230591252014699333"],
      bannerimages: [
        { id: 0, imgSrc: require("../assets/images/a16.jpg") }
        // { id: 1, imgSrc: require("../assets/images/a18.jpg") }
      ],
      middleimages: [{ id: 0, imgSrc: require("../assets/images/none.png") }]
    };
  },

  mounted() {
    // 上拉加载
  },
  // eslint-disable-next-line space-before-function-paren
  // created:vue生命周期中的钩子函数，在这个时间点，data中的数据已经注入到响应式系统中
  created() {},

  methods: {
    afterRead(file) {
      // 此时可以自行将文件上传至服务器
      console.log(file);
    },
    //弹出提示
    showbank() {
      this.$toast({
        message: "请认真填写开户银行名称，否则后果自负"
      });
    },
    showbankNumber() {
      this.$toast({
        message: "请认真填写银行卡号，否则后果自负"
      });
    },
    addacount() {
      let compellation = this.compellation;
      let phone = this.phone;
      let bank = this.bank;
      let cardnumber = this.cardnumber;
      //姓名验证
      if (!compellation) {
        this.$toast({
          message: "请输入真实姓名！"
        });
      } else if (!phone) {
        this.$toast({
          message: "请输入手机号码！"
        });
      } else if (!bank) {
        this.$toast({
          message: "请输入开户银行！"
        });
      } else if (!cardnumber) {
        this.$toast({
          message: "请输入银行卡号！"
        });
      } else if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(compellation)) {
        this.$toast({
          message: "请输入正确真实姓名！"
        });
      } else if (!/^[1][3-9][0-9]{9}$/.test(phone)) {
        this.$toast({
          message: "请输入正确手机号！"
        });
      } else if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(bank)) {
        this.$toast({
          message: "请输入正确开户银行！"
        });
      } else if (!/^([1-9]{1})(\d{14}|\d{18})$/.test(cardnumber)) {
        this.$toast({
          message: "请输入正确银行卡号！"
        });
      } else {
        for (var i = 0; i < this.compellationarr.length; i++) {
          if (
            compellation == this.compellationarr[i] &&
            phone == this.phonearr[i] &&
            bank == this.bankarr[i] &&
            cardnumber == this.cardnumberarr[i]
          ) {
            this.$toast({
              message: "输入成功！"
            });
          }
        }
      }
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* //自定义.css的样式路径 */
/* @import "../css/HomePage.css"; */

* {
  padding: 0;
  margin: 0;
}
body {
  background-color: #f6f6f6;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: 0;
  display: block;
}
div {
  display: block;
  box-sizing: border-box;
}

.all-body {
  width: 100%;
  height: 100%;
  background-color: #f6f6f6;
}

.shadow {
  height: 1px;
  width: 100%;
  background: #f6f6f6;
}

.TopList {
  display: flex;
  width: 100%;
  height: 50px;
  font-size: 20px;
  text-align: left;
  background: #ffffff;
  line-height: 50px;
}
.Backlink {
  margin-top: 15px;
  margin-left: 15px;
  color: #888;
}
.TopList-span {
  display: flex;
  height: 20px;
  margin-top: 0px;
  margin-left: 110px;
  font-size: 15px;
  width: 60%;
}

.banner {
  width: 100%;
  height: 100%;
}
.hello-1 {
  width: 100%;
  height: auto;
  padding: 0 2.6%;
  background-color: #ffffff;
  text-align: left;
}

.hello-1 img {
  width: 99%;
  height: 150px;
  border-radius: 10px;
  pointer-events: none;
}

li {
  position: absolute;
}

.cell-Group {
  height: auto;
}
.van-cell--required::before {
  position: absolute;
  left: 0px;
  color: #ee0a24;
  font-size: 14px;
  content: "*";
}
.cell-List {
  display: flex;
  height: 40px;
  line-height: 40px;
  padding-left: 8px;
}
.cell-List-2 {
  display: flex;
  height: 130px;
  line-height: 48px;
  padding-left: 8px;
  color: #969799;
}
.updateImg {
  margin-top: 15px;
  margin-left: 95px;
}

.lastadd {
  background: #fff;
  width: 100%;
  padding: 30px 6% 0;
}

.lastadd {
  width: 100%;
  height: 100px;
  color: #fff;
  line-height: 50px;
  font-size: 18px;
}
.add-button {
  width: 100%;
  font-size: 18px;
  letter-spacing: 1px;
  height: 42px;
  line-height: 42px;
}

.adddiv {
  width: 100%;
  height: 315px;
  background: #f6f6f6;
}
</style>
